<?php

/*
*
* BEGIN ajaxhandler.php
*
*
* Dazzler Server Client Communication Interface - Ajax Handler
* @Description: handles AJAX calls for site and routes them to the ajax controller
* @Authors: Salman Noor, Wits University
* @Copyright: © Wits University 2011 - All Rights Reserved
* @License: BSD License (http://www.linfo.org/bsdlicense.html)
*
*
* BEGIN CHANGELOG
* Developers working on thee files are REQUIRED to maintain this CHANGELOG.
* Please ensure you follow the Changelog Guidelines: http://code.google.com/p/dazzler/wiki/DazzlerDevelopGuideline?ts=1315476570&updated=DazzlerDevelopGuideline
* !==================================================================================================================================================================
*
* VERSION 1.0.0
*	+ File Created, Salman, 14 September 2011
*
* ==================================================================================================================================================================!
* END CHANGELOG
*/


/*******************************************************************************************************************************************************************
*
* BEGIN Direct Call Check
*
/******************************************************************************************************************************************************************/
global $doNotCallThisScriptDirectly;
if ($doNotCallThisScriptDirectly != 1)
{
	/* Read the ini language file */
	$ini_lang_array = array();
	$clientlang = explode(",", strtolower($_SERVER['HTTP_ACCEPT_LANGUAGE']));
	$lang_ini_array = (file_exists("lang/" . trim($clientlang[0]) . ".ini")) ? parse_ini_file("lang/" . trim($clientlang[0]) . ".ini", true) : parse_ini_file("lang/en.ini", true);
	die ($lang_ini_array['ERRORS']['doNotCallThisScriptDirectly']);
}
/*******************************************************************************************************************************************************************
*
* END Direct Call Check
*
/******************************************************************************************************************************************************************/

/*******************************************************************************************************************************************************************
* BEGIN Marshall request types {POST, GET} but only POST are handled
/******************************************************************************************************************************************************************/
include_once('ajaxcontroller.php');

$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : null;

 if ($action != null)
{
    $parameters = isset($_REQUEST['parameters']) ? $_REQUEST['parameters'] : null;
    $ajaxcontroller = new ajaxcontroller();
    $ajaxcontroller->dispatch($action);
}
else
{
   trigger_error("Ajax parameters are not set properly. An action is not defined", E_USER_ERROR);
}
/*******************************************************************************************************************************************************************
* END Marshall request types
/******************************************************************************************************************************************************************/

/*
*
* END ajaxhandler.php
*
*/

?>
